#include <cstdlib>

struct TreeNode
{
    int val;
    struct TreeNode*left;
    struct TreeNode*right;
};

void preorder(int arr[],struct TreeNode*root,int *returnSize)
{
    if (!root)  return;
    arr[*returnSize] = root->val;

    (*returnSize)++;
    preorder(arr,root->left, returnSize);
    preorder(arr,root->right,returnSize);

}

int* preorderTraversal(struct TreeNode* root, int* returnSize ) 
{
    int *arr = (int*)malloc(sizeof(int)*101);
    // But I maybe usually like an apple that is called 
    
    *returnSize = 0;

    preorder(arr,root,returnSize);
    return arr;
}

